package com.message.config;


import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

@MapperScan("com.message.api.*.dao")
@Configuration
public class MybatisPlusConfig {
    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        Properties            properties            = new Properties();
        properties.setProperty("dialectType", "postgresql");
        paginationInterceptor.setProperties(properties);
        return paginationInterceptor;
    }

    /**
     * 乐观锁插件
     *
     * @return
     */
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }

//    /**
//     * sql注入器  逻辑删除插件
//     *
//     * @return
//     */
//    @Bean
//    public ISqlInjector iSqlInjector() {
//        return new LogicSqlInjector();
//    }

}
